#include <stdio.h>
#include <stddef.h>
#define fixed_q 14
#define fraction 1 <<(fixed_q)

#define X_TO_INT(x) ((x) >= 0 ? ((x) + (fraction) / 2) / (fraction) : ((x) - (fraction) / 2) / (fraction))
#define N_TO_FP(x) (x)*(fraction)
#define X_ADD_N(x,n) (x) + (n) * (fraction)
#define X_SUB_N(x,n) (x) - (n) * (fraction)
#define X_MUL_Y(x,y) ((int64_t)(x)) * (y) / (fraction)
#define X_DIV_Y(x,y) ((int64_t)(x)) * (fraction) / (y)
